package application;

/***************
 * 
 * This is a singleton class that is used for game
 * Session data such as:
 *   1) List of available games retrieved from the server
 *   3) Player ranking data from the server
 *   4) Game to join - variable is used to store the game
 *      id requested by a player to join
 * 
***************/
import java.util.ArrayList;
import java.util.List;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

public class PreGameScreenSession {
	private static PreGameScreenSession instance = null;
	
	List<String> myAvailableGames;
	static String requestedGameToJoin;
	
	static ObservableList<PreGameScreenPlayerRanking> playerStatsData;
	
	public static PreGameScreenSession getInstance(){
		if(instance == null){
			
			instance = new PreGameScreenSession();
			
			/* Create a observable array list to create dummy player
			   ranking data. This should be retrieved from the server
			   instead of being statically set in this manner.
			*/
			playerStatsData = FXCollections.observableArrayList(
		    		new PreGameScreenPlayerRanking("Alex Tribeck", 100),
		    		new PreGameScreenPlayerRanking("Vanna White", 100),
		    		new PreGameScreenPlayerRanking("Jay Leno", 100),
		    		new PreGameScreenPlayerRanking("Geoge W. Bush", 3)
				);
			
			// Initialize the requestedGameToJoin
			requestedGameToJoin = null;

		}
		
		return instance;
	}
	
	private PreGameScreenSession(){
		myAvailableGames = new ArrayList<String>();
		
	}
	
	public int getListLength()
	{
		return myAvailableGames.size();
	}

	public void printList()
	{
		for (int i=0; i < this.myAvailableGames.size(); i++) {
			String element = this.myAvailableGames.get(i);
			System.out.println(element);
		}
	}
}
